package com.youhp.spire.xls.demo.DrawingObjects;

import com.spire.xls.*;
import com.spire.xls.core.*;

public class InsertControls {
    public static void main(String[] args) {
        //Open xls document
        Workbook workbook = new Workbook();
        workbook.loadFromFile("data/InsertControls.xlsx");
        //Get the first worksheet
        Worksheet worksheet = workbook.getWorksheets().get(0);
        //Add a textbox
        ITextBoxShape textbox = worksheet.getTextBoxes().addTextBox(9, 2, 25, 100);
        textbox.setText("Hello World");
        //Add a checkbox
        ICheckBox checkbox = worksheet.getCheckBoxes().addCheckBox(11, 2, 15, 100);
        checkbox.setCheckState(CheckState.Checked);
        checkbox.setText("Check Box 1");
        //Add a RadioButton
        IRadioButton radiobutton = worksheet.getRadioButtons().add(13, 2, 15, 100);
        radiobutton.setText("Option 1");
        //Add a combobox
        IComboBoxShape combobox = worksheet.getComboBoxes().addComboBox(15, 2, 15, 100);
        combobox.setListFillRange(worksheet.getCellRange("A41:A47"));
        //Save a file
        workbook.saveToFile("output/InsertControls.xlsx", ExcelVersion.Version2013);
    }
}
